package modelimplementation


type HourlyClassification struct{
	itsTimeCards Dictionary
	itsRate float32
}
func(h *HourlyClassification) NewHourLyClassification(hourlyRate float32) *HourlyClassification{
	h.itsRate = hourlyRate
	return h
}

func(h *HourlyClassification) GetRate() float32{
	return h.itsRate
}
func(h *HourlyClassification) GetTimeCard(date DateTime) *TimeCard{
	return &h.itsTimeCards[date]
}


func(h *HourlyClassification) AddTimeCard(tc TimeCard){
	h.itsTimeCards.Add(tc.GetDate(),tc)
}

func(h *HourlyClassification) CalculatePayForTimeCard(tc TimeCard) float32{
	hours := tc.GetHours();
	overtime := Math.Max(0.0, hours - 8.0)
	straightTime := hours - overtime
	return (straightTime * itsRate + overtime * itsRate * 1.5)
}

func(h *HourlyClassification) CalculatePay(pc Paycheck) float32{
	var totalPay float32 = 0
	payPeriodEndDate := pc.GetPayPeriodEndDate()
	date := h.itsTimeCards.Keys 
	for i := range date {
		tc := h.itsTimeCards[date]
		dt1 := pc.GetPayPeriodStartDate()
		dt2 := pc.GetPayPeriodEndDate()
		if date >= dt1 && date <= dt2 {
			totalPay += CalculatePayForTimeCard(tc)
		}

	}
	return totalPay
}
